/* eslint-disable */
import _m0 from "protobufjs/minimal";
import { FieldMask } from "../../google/protobuf/field_mask";
import { Visibility } from "./common";
import { PlanType } from "./subscription_service";

export const protobufPackage = "slash.api.v1";

export interface WorkspaceProfile {
  /** Current workspace mode: dev, prod. */
  mode: string;
  /** Current workspace version. */
  version: string;
  /** The workspace plan. */
  plan: PlanType;
  /** Whether to enable other users to sign up. */
  enableSignup: boolean;
  /** The custom style. */
  customStyle: string;
  /** The custom script. */
  customScript: string;
}

export interface WorkspaceSetting {
  licenseKey: string;
  /** Whether to enable other users to sign up. */
  enableSignup: boolean;
  /** The instance URL. */
  instanceUrl: string;
  /** The custom style. */
  customStyle: string;
  /** The custom script. */
  customScript: string;
  /** The auto backup setting. (Unimplemented) */
  autoBackup:
    | AutoBackupWorkspaceSetting
    | undefined;
  /** The default visibility of shortcuts and collections. */
  defaultVisibility: Visibility;
}

export interface AutoBackupWorkspaceSetting {
  /** Whether auto backup is enabled. */
  enabled: boolean;
  /**
   * The cron expression for auto backup.
   * For example, "0 0 0 * * *" means backup at 00:00:00 every day.
   * See https://en.wikipedia.org/wiki/Cron for more details.
   */
  cronExpression: string;
  /** The maximum number of backups to keep. */
  maxKeep: number;
}

export interface GetWorkspaceProfileRequest {
}

export interface GetWorkspaceProfileResponse {
  /** The workspace profile. */
  profile: WorkspaceProfile | undefined;
}

export interface GetWorkspaceSettingRequest {
}

export interface GetWorkspaceSettingResponse {
  /** The user setting. */
  setting: WorkspaceSetting | undefined;
}

export interface UpdateWorkspaceSettingRequest {
  /** The user setting. */
  setting:
    | WorkspaceSetting
    | undefined;
  /** The update mask. */
  updateMask: string[] | undefined;
}

export interface UpdateWorkspaceSettingResponse {
  /** The user setting. */
  setting: WorkspaceSetting | undefined;
}

function createBaseWorkspaceProfile(): WorkspaceProfile {
  return { mode: "", version: "", plan: 0, enableSignup: false, customStyle: "", customScript: "" };
}

export const WorkspaceProfile = {
  encode(message: WorkspaceProfile, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.mode !== "") {
      writer.uint32(10).string(message.mode);
    }
    if (message.version !== "") {
      writer.uint32(18).string(message.version);
    }
    if (message.plan !== 0) {
      writer.uint32(24).int32(message.plan);
    }
    if (message.enableSignup === true) {
      writer.uint32(32).bool(message.enableSignup);
    }
    if (message.customStyle !== "") {
      writer.uint32(42).string(message.customStyle);
    }
    if (message.customScript !== "") {
      writer.uint32(50).string(message.customScript);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): WorkspaceProfile {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseWorkspaceProfile();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.mode = reader.string();
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.version = reader.string();
          continue;
        case 3:
          if (tag !== 24) {
            break;
          }

          message.plan = reader.int32() as any;
          continue;
        case 4:
          if (tag !== 32) {
            break;
          }

          message.enableSignup = reader.bool();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }

          message.customStyle = reader.string();
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }

          message.customScript = reader.string();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<WorkspaceProfile>): WorkspaceProfile {
    return WorkspaceProfile.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<WorkspaceProfile>): WorkspaceProfile {
    const message = createBaseWorkspaceProfile();
    message.mode = object.mode ?? "";
    message.version = object.version ?? "";
    message.plan = object.plan ?? 0;
    message.enableSignup = object.enableSignup ?? false;
    message.customStyle = object.customStyle ?? "";
    message.customScript = object.customScript ?? "";
    return message;
  },
};

function createBaseWorkspaceSetting(): WorkspaceSetting {
  return {
    licenseKey: "",
    enableSignup: false,
    instanceUrl: "",
    customStyle: "",
    customScript: "",
    autoBackup: undefined,
    defaultVisibility: 0,
  };
}

export const WorkspaceSetting = {
  encode(message: WorkspaceSetting, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.licenseKey !== "") {
      writer.uint32(10).string(message.licenseKey);
    }
    if (message.enableSignup === true) {
      writer.uint32(16).bool(message.enableSignup);
    }
    if (message.instanceUrl !== "") {
      writer.uint32(26).string(message.instanceUrl);
    }
    if (message.customStyle !== "") {
      writer.uint32(34).string(message.customStyle);
    }
    if (message.customScript !== "") {
      writer.uint32(42).string(message.customScript);
    }
    if (message.autoBackup !== undefined) {
      AutoBackupWorkspaceSetting.encode(message.autoBackup, writer.uint32(50).fork()).ldelim();
    }
    if (message.defaultVisibility !== 0) {
      writer.uint32(56).int32(message.defaultVisibility);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): WorkspaceSetting {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseWorkspaceSetting();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.licenseKey = reader.string();
          continue;
        case 2:
          if (tag !== 16) {
            break;
          }

          message.enableSignup = reader.bool();
          continue;
        case 3:
          if (tag !== 26) {
            break;
          }

          message.instanceUrl = reader.string();
          continue;
        case 4:
          if (tag !== 34) {
            break;
          }

          message.customStyle = reader.string();
          continue;
        case 5:
          if (tag !== 42) {
            break;
          }

          message.customScript = reader.string();
          continue;
        case 6:
          if (tag !== 50) {
            break;
          }

          message.autoBackup = AutoBackupWorkspaceSetting.decode(reader, reader.uint32());
          continue;
        case 7:
          if (tag !== 56) {
            break;
          }

          message.defaultVisibility = reader.int32() as any;
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<WorkspaceSetting>): WorkspaceSetting {
    return WorkspaceSetting.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<WorkspaceSetting>): WorkspaceSetting {
    const message = createBaseWorkspaceSetting();
    message.licenseKey = object.licenseKey ?? "";
    message.enableSignup = object.enableSignup ?? false;
    message.instanceUrl = object.instanceUrl ?? "";
    message.customStyle = object.customStyle ?? "";
    message.customScript = object.customScript ?? "";
    message.autoBackup = (object.autoBackup !== undefined && object.autoBackup !== null)
      ? AutoBackupWorkspaceSetting.fromPartial(object.autoBackup)
      : undefined;
    message.defaultVisibility = object.defaultVisibility ?? 0;
    return message;
  },
};

function createBaseAutoBackupWorkspaceSetting(): AutoBackupWorkspaceSetting {
  return { enabled: false, cronExpression: "", maxKeep: 0 };
}

export const AutoBackupWorkspaceSetting = {
  encode(message: AutoBackupWorkspaceSetting, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.enabled === true) {
      writer.uint32(8).bool(message.enabled);
    }
    if (message.cronExpression !== "") {
      writer.uint32(18).string(message.cronExpression);
    }
    if (message.maxKeep !== 0) {
      writer.uint32(24).int32(message.maxKeep);
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): AutoBackupWorkspaceSetting {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseAutoBackupWorkspaceSetting();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 8) {
            break;
          }

          message.enabled = reader.bool();
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.cronExpression = reader.string();
          continue;
        case 3:
          if (tag !== 24) {
            break;
          }

          message.maxKeep = reader.int32();
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<AutoBackupWorkspaceSetting>): AutoBackupWorkspaceSetting {
    return AutoBackupWorkspaceSetting.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<AutoBackupWorkspaceSetting>): AutoBackupWorkspaceSetting {
    const message = createBaseAutoBackupWorkspaceSetting();
    message.enabled = object.enabled ?? false;
    message.cronExpression = object.cronExpression ?? "";
    message.maxKeep = object.maxKeep ?? 0;
    return message;
  },
};

function createBaseGetWorkspaceProfileRequest(): GetWorkspaceProfileRequest {
  return {};
}

export const GetWorkspaceProfileRequest = {
  encode(_: GetWorkspaceProfileRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetWorkspaceProfileRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetWorkspaceProfileRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetWorkspaceProfileRequest>): GetWorkspaceProfileRequest {
    return GetWorkspaceProfileRequest.fromPartial(base ?? {});
  },

  fromPartial(_: DeepPartial<GetWorkspaceProfileRequest>): GetWorkspaceProfileRequest {
    const message = createBaseGetWorkspaceProfileRequest();
    return message;
  },
};

function createBaseGetWorkspaceProfileResponse(): GetWorkspaceProfileResponse {
  return { profile: undefined };
}

export const GetWorkspaceProfileResponse = {
  encode(message: GetWorkspaceProfileResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.profile !== undefined) {
      WorkspaceProfile.encode(message.profile, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetWorkspaceProfileResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetWorkspaceProfileResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.profile = WorkspaceProfile.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetWorkspaceProfileResponse>): GetWorkspaceProfileResponse {
    return GetWorkspaceProfileResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetWorkspaceProfileResponse>): GetWorkspaceProfileResponse {
    const message = createBaseGetWorkspaceProfileResponse();
    message.profile = (object.profile !== undefined && object.profile !== null)
      ? WorkspaceProfile.fromPartial(object.profile)
      : undefined;
    return message;
  },
};

function createBaseGetWorkspaceSettingRequest(): GetWorkspaceSettingRequest {
  return {};
}

export const GetWorkspaceSettingRequest = {
  encode(_: GetWorkspaceSettingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetWorkspaceSettingRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetWorkspaceSettingRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetWorkspaceSettingRequest>): GetWorkspaceSettingRequest {
    return GetWorkspaceSettingRequest.fromPartial(base ?? {});
  },

  fromPartial(_: DeepPartial<GetWorkspaceSettingRequest>): GetWorkspaceSettingRequest {
    const message = createBaseGetWorkspaceSettingRequest();
    return message;
  },
};

function createBaseGetWorkspaceSettingResponse(): GetWorkspaceSettingResponse {
  return { setting: undefined };
}

export const GetWorkspaceSettingResponse = {
  encode(message: GetWorkspaceSettingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.setting !== undefined) {
      WorkspaceSetting.encode(message.setting, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): GetWorkspaceSettingResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseGetWorkspaceSettingResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.setting = WorkspaceSetting.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<GetWorkspaceSettingResponse>): GetWorkspaceSettingResponse {
    return GetWorkspaceSettingResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<GetWorkspaceSettingResponse>): GetWorkspaceSettingResponse {
    const message = createBaseGetWorkspaceSettingResponse();
    message.setting = (object.setting !== undefined && object.setting !== null)
      ? WorkspaceSetting.fromPartial(object.setting)
      : undefined;
    return message;
  },
};

function createBaseUpdateWorkspaceSettingRequest(): UpdateWorkspaceSettingRequest {
  return { setting: undefined, updateMask: undefined };
}

export const UpdateWorkspaceSettingRequest = {
  encode(message: UpdateWorkspaceSettingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.setting !== undefined) {
      WorkspaceSetting.encode(message.setting, writer.uint32(10).fork()).ldelim();
    }
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateWorkspaceSettingRequest {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateWorkspaceSettingRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.setting = WorkspaceSetting.decode(reader, reader.uint32());
          continue;
        case 2:
          if (tag !== 18) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateWorkspaceSettingRequest>): UpdateWorkspaceSettingRequest {
    return UpdateWorkspaceSettingRequest.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateWorkspaceSettingRequest>): UpdateWorkspaceSettingRequest {
    const message = createBaseUpdateWorkspaceSettingRequest();
    message.setting = (object.setting !== undefined && object.setting !== null)
      ? WorkspaceSetting.fromPartial(object.setting)
      : undefined;
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

function createBaseUpdateWorkspaceSettingResponse(): UpdateWorkspaceSettingResponse {
  return { setting: undefined };
}

export const UpdateWorkspaceSettingResponse = {
  encode(message: UpdateWorkspaceSettingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
    if (message.setting !== undefined) {
      WorkspaceSetting.encode(message.setting, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },

  decode(input: _m0.Reader | Uint8Array, length?: number): UpdateWorkspaceSettingResponse {
    const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseUpdateWorkspaceSettingResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          if (tag !== 10) {
            break;
          }

          message.setting = WorkspaceSetting.decode(reader, reader.uint32());
          continue;
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skipType(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateWorkspaceSettingResponse>): UpdateWorkspaceSettingResponse {
    return UpdateWorkspaceSettingResponse.fromPartial(base ?? {});
  },

  fromPartial(object: DeepPartial<UpdateWorkspaceSettingResponse>): UpdateWorkspaceSettingResponse {
    const message = createBaseUpdateWorkspaceSettingResponse();
    message.setting = (object.setting !== undefined && object.setting !== null)
      ? WorkspaceSetting.fromPartial(object.setting)
      : undefined;
    return message;
  },
};

export type WorkspaceServiceDefinition = typeof WorkspaceServiceDefinition;
export const WorkspaceServiceDefinition = {
  name: "WorkspaceService",
  fullName: "slash.api.v1.WorkspaceService",
  methods: {
    getWorkspaceProfile: {
      name: "GetWorkspaceProfile",
      requestType: GetWorkspaceProfileRequest,
      requestStream: false,
      responseType: GetWorkspaceProfileResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              27,
              18,
              25,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              112,
              114,
              111,
              102,
              105,
              108,
              101,
            ]),
          ],
        },
      },
    },
    getWorkspaceSetting: {
      name: "GetWorkspaceSetting",
      requestType: GetWorkspaceSettingRequest,
      requestStream: false,
      responseType: GetWorkspaceSettingResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              27,
              18,
              25,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
            ]),
          ],
        },
      },
    },
    updateWorkspaceSetting: {
      name: "UpdateWorkspaceSetting",
      requestType: UpdateWorkspaceSettingRequest,
      requestStream: false,
      responseType: UpdateWorkspaceSettingResponse,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [
            new Uint8Array([
              19,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              44,
              117,
              112,
              100,
              97,
              116,
              101,
              95,
              109,
              97,
              115,
              107,
            ]),
          ],
          578365826: [
            new Uint8Array([
              36,
              58,
              7,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              50,
              25,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
            ]),
          ],
        },
      },
    },
  },
} as const;

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;
